﻿
using MMPS.Common;
using MMPS.Entity.POCOMdel;
using MMPS.Entity.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MMPS.Business
{
   public class ShopsService : BaseService<Shops>
    {
        public OperateResult GetShops(ShopsViewModel ShopVM)
        {
            var query = PredicateExtensions.True<Shops>();
            if (!string.IsNullOrWhiteSpace(ShopVM.shopsname))
            {
                query = query.And(s => s.S_Name.Contains(ShopVM.shopsname));
            }
            int rowCount = 0;
            var pageDate = GetList(ShopVM.page, ShopVM.rows, ref rowCount, query, s => s.S_ID, true).Select(u => new GetPageShopsView
            {
                S_ID = u.S_ID,
                S_Name = u.S_Name,
                S_Address = u.S_Address,
                S_Category = u.S_Category,
                S_ContactName = u.S_ContactName,
                S_ContactTel = u.S_ContactTel,
                S_CreateTime = u.S_CreateTime,
                S_IsHasSetAdmin = u.S_IsHasSetAdmin,
                S_Remark = u.S_Remark,
            }).ToList();
            var pageViewModel = new DatgRIDViewModel { total = rowCount, rows = pageDate };
            return new OperateResult(ResultStatus.Success, "", pageViewModel);
        }
    }
}
